#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "iconhelper.h"

#include <QList>
#include <QScopedPointer>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    SaveFontImages();
}

MainWindow::~MainWindow() { delete ui; }

struct FontImageCode {
    int code;
    QString name;
    QString alias;
};

void MainWindow::SaveFontImages() {
    // QScopedPointer<IconHelper> iconHelper(
    //     new IconHelper(":/fa-regular-400.ttf", "Font Awesome 6 Pro
    //     Regular"));
    QScopedPointer<IconHelper> iconHelper(
        new IconHelper(":/fa-solid-900.ttf", "Font Awesome 6 Pro Solid"));

    QString color("#32bea6");
    QString fileExt(".png");
    // int fontSize = 480;
    // int imageWidth = 600;
    // int imageHeight = 600;

    int fontSize = 252;
    int imageWidth = 256;
    int imageHeight = 256;

    QList<FontImageCode> images{
        {0xf01d, "circle-play", "Play"}, {0xf28b, "circle-pause", "Pause"},
        {0xf28d, "circle-stop", "Stop"},

        {0xf048, "backward-step"},       {0x23ee, "backward-fast", "Previous"},
        {0x23ea, "backward", "Slow"},    {0x25b6, "play", "Play2"},
        {0x23f8, "pause", "Pause2"},     {0x23f9, "stop", "Stop2"},

        {0x23e9, "forward", "Fast"},     {0x23ed, "forward-fast", "Next"},
        {0xf051, "forward-step"},        {0x23cf, "eject"}};

    for (auto &f : images) {
        QPixmap pix = iconHelper->getPixmap1(color, f.code, fontSize,
                                             imageWidth, imageHeight);
        QImage img = pix.toImage();
        QString fileName =
            f.alias.isEmpty() ? (f.name + fileExt) : (f.alias + fileExt);
        img.save(fileName);
    }
}
